//
//  VideoCaptureViewModel.m
//  OnionHome
//
//  Created by fengjie on 2019/10/8.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "VideoCaptureViewModel.h"


@implementation VideoCaptureViewModel

- (void)addVideoFile:(NSString *)videoFilePath
{
    VideoCaptureItem *item = [self.videoItemList bk_match:^BOOL(VideoCaptureItem *obj) {
        return [obj.filePath isEqualToString:videoFilePath];
    }];
    
    if (!item) {
        NSMutableArray *tempArr = [NSMutableArray arrayWithArray:self.videoItemList];
        item = [[VideoCaptureItem alloc] init];
        item.filePath = videoFilePath;

        [tempArr addObject:item];
        self.videoItemList = tempArr;
    }
}

- (void)removePreviousVideoFile
{
    NSMutableArray *tempArr = [NSMutableArray arrayWithArray:self.videoItemList];
    [tempArr removeObject:self.videoItemList.lastObject];
    self.videoItemList = tempArr;
}

- (void)removeVideoFile:(NSString *)videoFilePath
{
    VideoCaptureItem *item = [self.videoItemList bk_match:^BOOL(VideoCaptureItem *obj) {
        return [obj.filePath isEqualToString:videoFilePath];
    }];
    
    if (item) {
        NSMutableArray *tempArr = [NSMutableArray arrayWithArray:self.videoItemList];
        [tempArr removeObject:item];
        self.videoItemList = tempArr;
    }
}

@end
